home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / Universal Interfaces / PPCCIncludes / generic.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-13  |  2.6 KB  |  82 lines  |  [TEXT/MPS ]

  1. /*ident    "@(#)C++env:incl-master/proto-headers/generic.h    1.1" */
  2. /**************************************************************************
  3.             Copyright (c) 1984 AT&T
  4.                 All Rights Reserved      
  5.  
  6.     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
  7.     
  8.     The copyright notice above does not evidence any       
  9.     actual or intended publication of such source code.
  10.  
  11. *****************************************************************************/
  12.  
  13. #ifndef __GENERIC__
  14.  
  15. #define __GENERIC__ 1
  16.  
  17. /* macros to paste tokens together to form new names */
  18. /* 4.2BSD and System V cpp's have different mechanisms for
  19.    pasting tokens together, but 4.3BSD agrees with System V.
  20.    ANSI C has defined a new way.
  21. */
  22.  
  23. #if applec || __LandShark__ || powerc
  24. /* ANSI C preprocessors will not expand the arguments to a macro;
  25.  * so we need to add a level of indirection to allow macro expansion of
  26.  * arguments.  (Reiser preprocessors allowed the first arg to be expanded;
  27.  * this method will allow both to be expanded, which is better than none.)
  28.  */
  29. #define name2(a,b)      _name2_aux(a,b)
  30. #define _name2_aux(a,b)      a##b
  31. #define name3(a,b,c)    _name3_aux(a,b,c)
  32. #define _name3_aux(a,b,c)    a##b##c
  33. #define name4(a,b,c,d)  _name4_aux(a,b,c,d)
  34. #define _name4_aux(a,b,c,d)  a##b##c##d
  35.  
  36. #else 
  37.  
  38. #os bsd3 svr2 svr3 sunos3 sunos4 hpux uts
  39. #define name2(a,b)    a/**/b
  40. #define name3(a,b,c)    a/**/b/**/c
  41. #define name4(a,b,c,d)    a/**/b/**/c/**/d
  42. #endos
  43. #os bsd2 alliant
  44. #define name2(a,b) a\
  45. b
  46. #define name3(a,b,c) a\
  47. b\
  48. c
  49. #define name4(a,b,c,d) a\
  50. b\
  51. c\
  52. d
  53. #endos
  54.  
  55. #endif
  56.  
  57. #ifdef applec 
  58. // Alas, MPW C++ doesn't have an ANSI C conformant preprocessor, so
  59. //  the AT&T code as given doesn't work. The code below will work for 
  60. //  MPW C++, but **NOT** for a compiler with an ANSI C conformant
  61. //  preprocessor because the preprocessor isn't supposed to expand 
  62. //  operands of ##. Undefine applec to use this header with other
  63. //  compilers. Thanks to Allen Cecil for the suggested "fix". 
  64. # define declare(a,t)        a##declare(t)
  65. # define implement(a,t)      a##implement(t)
  66. # define declare2(a,t1,t2)   a##declare2(t1,t2)
  67. # define implement2(a,t1,t2) a##implement2(t1,t2)
  68. #else /* applec */
  69. #define declare(a,t) name2(a,declare)(t)
  70. #define implement(a,t) name2(a,implement)(t)
  71. #define declare2(a,t1,t2) name2(a,declare2)(t1,t2)
  72. #define implement2(a,t1,t2) name2(a,implement2)(t1,t2)
  73. #endif /* applec */
  74.  
  75.  
  76. extern genericerror(int,char*);
  77. typedef int (*GPT)(int,char*);
  78. #define set_handler(generic,type,x) name4(set_,type,generic,_handler)(x)
  79. #define errorhandler(generic,type) name3(type,generic,handler)
  80. #define callerror(generic,type,a,b) (*errorhandler(generic,type))(a,b)
  81. #endif
  82.